package com.ykt.validator;

import com.jfinal.core.Controller;

/**
 * @author long.hua
 * @version 1.0.0
 * @since 2016-03-01 22:52
 */
public class UserAddressValidator {

    public static class CreateValidator extends BaseValidator{

        @Override
        protected void validate(Controller c) {
            validateInteger("provinceId", "provinceIdMsg", "省/市ID不能为空！");
            validateInteger("cityId", "cityIdMsg", "市/区ID不能为空！");
            validateInteger("districtId", "districtIdMsg", "区/县ID不能为空！");
            validateRequired("address", "addressMsg", "详细地址不能为空！");
            validateRequired("receiptName", "receiptNameMsg", "收货人名称不能为空！");
            validateRequired("receiptPhone", "receiptPhoneMsg", "收货人电话不能为空！");
        }

        @Override
        protected void handleError(Controller c) {
            c.renderJson(super.toJsonText(c));
        }
    }

    public static class AddressIdValidator extends BaseValidator{

        @Override
        protected void validate(Controller c) {
            validateInteger("addressId", "addressIdMsg", "地址ID不能为空！");
        }

        @Override
        protected void handleError(Controller c) {
            c.renderJson(super.toJsonText(c));
        }
    }
}
